<?php
/**
 * ExtIFrameAutoLoaderBase class file
 *
 * @author TrueSoftware B.V. (The Netherlands)
 * @link http://www.ext4yii.com
 * @copyright Copyright 2007-2010 TrueSoftwareB.V. all rights reserved.
 * @license http://www.ext4yii.com/license/
 *          EVALUATION VERSION - NOT FOR COMMERCIAL USE OR DISTRIBUTION.
 * @version 0.7.2
 */
 
 
abstract class ExtIFrameAutoLoaderBase extends ExtWidget
{
    public function parseNode(ExtHTMLParserNode $node,
            ExtASTWalker $astwalker)
    {
        parent::parseNode($node, $astwalker);
        if(!is_null($this->parent) && ($this->parent instanceof ExtPanel))
        {
            $autoload = new ExtJavaScriptObject();
            $autoload->addString('url', $this->getUrl());
            $autoload->addBoolean('iframe', true);

            if($this->parent instanceof ExtWindow)
                $autoload->addBoolean('loadOnce',!$this->getReloadOnShow());
            
            if($this->getShowLoadMask())
            {
                if(trim($this->getLoadMaskMsg())=="")
                    $autoload->addBoolean('mask',true);
                else
                {
                    $mask = new ExtJavaScriptObject();
                    $mask->addString('msg', $this->getLoadMaskMsg());
                    $autoload->addJavaScriptObject('mask', $mask);
                }
            }
            else
                $autoload->addBoolean('mask', false);

            $this->parent->setConfig('autoLoad',$this->JSImply($autoload->render()) );
            $this->parent->setAutoScroll(true);
            $this->parent->setPreventBodyReset(true);
            $node->shiftUp();
        }
    }

    public function renderConfig($asobject=true)
    {
        if(!is_null($this->parent) && ($this->parent instanceof ExtWindow))
        {
            $script = sprintf('Ext.getCmp("%s").on("show",function(){this.windowAutoLoad()})',
                $this->parent->getId());
            $this->getController()->addAfterInitScript($script);
            return null;
        }
        return null;
    }

}
?>
